import React, {PureComponent} from 'react';
import {Form, Input, Modal, Select, Steps,TreeSelect,Tree} from 'antd';
import DescriptionList from '@/components/DescriptionList';
const {Description} = DescriptionList;
const FormItem = Form.Item;
const {Step} = Steps;
const {TextArea} = Input;
const {Option} = Select;
const TreeNode = Tree.TreeNode;

/***
 * 文件扫描结果展示
 */
@Form.create()
class ScanResultForm extends PureComponent {

  state = {

  }


  render() {
    const {modalVisible,handleModalVisible,scanData} = this.props;
    const {scanResultList,} = this.state;
    const move = () => {
    }
    // console.error("scanData:"+scanData);


    const loop = data => data.map((item) => {
      // console.error("item.scanChildren:"+item.scanChildren);
      let title = item.dirName+" ";
      if(item.scanChildren){
        item.scanChildren.forEach(child => {
          title =title+ " '"+child.sensitiveName+":"+child.sensitiveNum+"次' "
        })
      }

      let showText = title;
      if(title.length>60){
        showText = showText.substring(0,60)+" .....";
      }

      if (item.children) {
        return (
          <TreeNode className="ant-tree-title" key={item.id} title={<span title={title}>{showText}</span>}>
            {loop(item.children||[])}
          </TreeNode>
        );
      }
      return <TreeNode key={item.id} title={title} />;
    });
    return (
      <Modal
        width={800}
        destroyOnClose
        title={'扫描结果'}
        visible={modalVisible}
        onCancel={() => handleModalVisible()}
        onOk={() => handleModalVisible()}
        maskClosable={false}
        bodyStyle={{padding: 0, overflow: 'auto'}}
      >
        <Tree
          width={640}
          showLine={true}
          showIcon={true}
          blockNode
          style={{marginLeft:20}}
        >
          {loop(scanData||[])}
        </Tree>
      </Modal>
    );
  }
}

export default ScanResultForm;
